1. Field of the Invention
This invention generally pertains to computer applications which are accessed simultaneously by multiple clients. In particular, the present invention is drawn to a method and system which allows multiple clients to simultaneously access and edit a database.
2. State of the Art
A database is a logically structured collection of data, organized to be accessed by, and useful to, a human user, a software application, or a machine based logic function. A database is generally embodied in the form of a computer program or software application residing within a storage device, but may simply be a set of rules for organizing and accessing data in a useful manner. A database system includes a computer for storing and manipulating the database, input/output (I/O) devices for entering data and displaying, or otherwise outputting, the results, and communication or network links to interconnect the various parts of the database system. The database system may be thought of as the physical system (e.g., the computer terminals, data links, I/O devices, memories, etc.) while the database itself represents the information to be stored and manipulated. In practice, however, the term database and the term database system, are often used interchangeably.
A database system having a database enables data to be conveniently stored, retrieved, manipulated, mathematically transformed, copied, or linked to data within the same database or different databases or files. This is achieved by storing data indexes and/or reference information along with the data of a database. Databases are typically stored on permanent or semi-permanent storage systems, often called non-volatile memory which enables data storage without an uninterrupted supply of power. By contrast, data in volatile memory must have a continuously uninterrupted supply of power, to avoid loss of data. U.S. Pat. No. 5,745,905 issued to Larsson et al., which pertains to database storage in memory, is herein incorporated by reference in its entirety.
A database system may be configured for use by multiple users. For example, a retail store may find it useful to maintain an inventory database linked to the cash registers, the warehouse, and the accounting department. An inventory database of this configuration might allow various activities within the store to be updated simultaneously. For instance, upon the occurrence of a sale, the cash registers recording the sales may update the retail inventory database to reflect the fact that the stock on-hand in the store has been reduced by the sale. When the database indicates that the stock on-hand in the store has dropped below a certain level, the warehouse, which is also linked to the database, is prompted to ship more merchandise to the store. Furthermore, the accounting department may also be linked to the database to update its cash flow and tax liability information based upon the information of the database. Accordingly, the database may be updated by either the cash register, upon making a sale, the warehouse, upon receiving/transferring goods, or the accounting department, upon the occurrence of a transaction.
The users of a database system are often referred to as clients. A database client may be a human user entering or modifying database data via a computer keyboard, digital pen, barcode wand, voice recognition system, or the like. A database client can also be a sensor, counter, detector, monitoring device, computer program or logic, or other like system capable of generating or modifying database data.
A database manager performs data operations such as transforming the value of the data, and manipulating the data by copying, moving, linking, or otherwise changing the state of the data. Another important function of the database manager is the control of access to the database. That is, the database manager controls client access to data within a database, including controlling simultaneous client access to data in a multi-user database. A database manager is typically a computer program/subprogram or software application that exercises a set of rules or logic which organize data and limit access to the data within a database. In the present context, the term database manager is used in reference to the computer or physical processing device within which the database manager function or logic resides.
FIGS. 1A-D illustrate a database manager 101 and clients 102-106. The database manager 101 is reflected in the figures in the form of a file server. In practice, the data manager 101 may be embodied in any of various types of computers or processing devices. The data manager function may be performed in the same type of computer as the clients. The physical configuration of the database manager in relation to the clients may take many forms, as shown in FIGS. 1A-D. For instance, the database manager 101 may be connected to the clients 102-106 in the bus configuration of FIG. 1A, the round-robin configuration of FIG. 1B, the star configuration of FIG. 1C, or the communication network configuration of FIG. 1D. In FIG. 1D the database manager 101 communicates with database clients 102-106 via a communications network 90. The communications network 90 may be the Internet, an intranet, a local area network (LAN), the PSTN, a wireless network, or other like network for communications among nodes or users.
In general, the database manager may be either centrally located, or the functions associated with the database manager may be distributed amongst various network nodes, resources and/or database clients. For example, in any of FIGS. 1A-1D, the database manager could either be solely located in one computer, such as computer 101, or the functions associated with the database manager could be distributed amongst the computers 101-106. In the case of a distributed database manager, it is desirable to have a scheme in place for communication among the different portions of the database manager to enable coordination of database manager operations. U.S. Pat. No. 5,761,672 to Samuelsson et al., pertaining to a distributed database system, is herein incorporated by reference.
In a multi-user database, the clients may access a database from a single access point at different times, or several clients may simultaneously access the database at once. The simultaneous access of a database by multiple clients can give rise to data corruption, that is, the inadvertent over-writing or modification of one client""s data by another client. For instance, one client may edit data and save it, over-writing the modifications of another client. In the present context, the terms edit and modify are used interchangeably, and include the acts of deleting, adding or in any way altering the data in a database. A database integrity scheme is required to avoid data corruption due to simultaneous database operations by multiple users, in which the multiple users edit the data of the database.
One conventional integrity scheme involves limiting access for the purpose of editing the database to only one client at a time. Under this scheme, only one client is permitted to access the database for the purposes of making changes to the data of a file or a record of the database. Other clients may be permitted to access a database record or file on a read-only basis, but are not allowed to edit the database. In other words, all but one client remain locked out of the database record/file for editing purposes. While such a scheme ensures integrity of the database, it unduly burdens the usefulness of having a multi-client database system.
According to another conventional database integrity scheme, a new, unique identifier of the record being modified is assigned when there are two or more clients attempting to simultaneously edit the same record. Thus, multi-user editing is allowed, but it results in multiple versions of the database record or of the entire database file. This database integrity scheme is disadvantageous because it requires excessive amounts of memory due to the saving and storage of multiple versions of the database. In addition, this scheme is not truly a multi-user database system since new iterations or versions of the same record or file are formed each time two or more clients seek to modify the same record.
Therefore, a need presently exists for an improved method of ensuring database integrity during multi-user editing of the database.
The present invention ensures database integrity while allowing simultaneous multiple-client access for editing the database. In general, the present invention accomplishes this by using a change counter value which tracks the modification status of various database records to avoid a data corruption situation. Accordingly, it is an object of the present invention to provide a method for multiple clients to access and save records to a database without data corruption.
In accordance with one aspect of the present invention, the above-identified and other objects are achieved for a first client accessing a database record. Upon allowing the first client to access the database record, a database manager stores a change counter value (CCV). The CCV has a first value corresponding to the state of the database when the first client accessed the database record. If a modified version of the database record is saved by a second client after the first client has accessed the record, the CCV is incremented. Then, if the first client seeks to save the database record, the database manager denies the first client""s request since the CCV value is changed, indicating that the first client would be overwriting the modifications of the second client.